package 补充;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TestCollections2 {//查找替换
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(35);
        list.add(70);
        list.add(26);
        list.add(102);
        list.add(90);
        //输出元素26在List集合中的索引
        System.out.println(Collections.binarySearch(list, 26));
        System.out.println("集合中最大的元素"+Collections.max(list));
        System.out.println("集合中最小的元素"+Collections.min(list));
        //在集合中用元素35替换元素26
        Collections.replaceAll(list,26,35);
        System.out.println(list);
        //输出元素35出现的次数
        System.out.println(Collections.frequency(list,35));


    }
}
